Personal tools

Lua/Client/ClientEffect/Static Functions/Create

From JC2-MP Documentation

< Lua‎ | Client‎ | ClientEffect
Jump to: navigation, search

Returns    ClientEffect
Prototype    ClientEffect.Create(AssetLocation, table arguments)
Description    No description


Argument table

Required values

Type Name Notes
Vector3 position
Angle angle
number effect_id From 0 to 467. Use this effects browser to find effect ids.

Examples

Create an explosion where you click

  1. effects = {}
  2.  
  3. Events:Subscribe("MouseDown", function(args)
  4. 	if args.button ~= 1 then
  5. 		return
  6. 	end
  7.  
  8. 	local result = Physics:Raycast(
  9. 		Camera:GetPosition(),
  10. 		Camera:GetAngle() * Vector3.Forward,
  11. 		0,
  12. 		100
  13. 	)
  14.  
  15. 	local spawnArgs = {
  16. 		position = result.position + result.normal * 0.25,
  17. 		angle = Angle(),
  18. 		effect_id = 35,
  19. 	}
  20.  
  21. 	local effect = ClientEffect.Create(AssetLocation.Game, spawnArgs)
  22.  
  23. 	table.insert(effects, effect)
  24. end)
  25.  
  26. -- Make sure to clean up everything on ModuleUnload.
  27. Events:Subscribe("ModuleUnload", function()
  28. 	for index, effect in ipairs(effects) do
  29. 		effect:Remove()
  30. 	end
  31. end)